package entity;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.Body;
import com.badlogic.gdx.physics.box2d.BodyDef;
import com.badlogic.gdx.physics.box2d.FixtureDef;
import com.badlogic.gdx.physics.box2d.PolygonShape;
import com.badlogic.gdx.physics.box2d.World;
import resources.Assets;
import resources.Input;
import screen.Stage;
import common.Constant;
import common.ShapeRenderer;


public abstract class Entity {
	public int type;
	public int id;
	protected World world;
	protected Sprite sprite;
	protected Body body;
	protected boolean remove;
	protected boolean isAnimaton;
	protected Stage stage;
	public int timeToDie;
	public int timeEnd;
	public int damage;
	public float x;
	public float y;
	public int state;
	public boolean attackplanevn = false;
	public boolean attackflagvn = false;
	public boolean attackplaneFighter = false;
	public boolean itemDrop = false;
	public float speedMissile;
	public boolean smart = false;
	public int width;
	public int height;
	
	public Entity(Stage stage, int type) {
		this.stage = stage;
		this.world = stage.world;
		this.type = type;
		
//		if (type == 1) sprite = new Sprite(Assets.manager.get("data/imagine/boat/china/1.png", Texture.class),102,98);
//		else if (type == Constant.BULLET) sprite = new Sprite(Assets.manager.get("data/imagine/Bom/1.png", Texture.class),27,6);
//		else if (type == Constant.EXPLOSION) return;
//		else if (type == 3) return;
//		BodyDef bodyDef = new BodyDef();
//		bodyDef.type = BodyDef.BodyType.DynamicBody;
//		bodyDef.position.set(1.0f, 3.0f);
//		body = world.createBody(bodyDef);
//		body.setGravityScale(0);
//		body.setLinearVelocity(1.0f, 0.0f);
//		PolygonShape shape = new PolygonShape();
//		shape.setAsBox(sprite.getWidth() / (2 * Constant.PIXELS_PER_METER),
//				sprite.getHeight() / (2 * Constant.PIXELS_PER_METER));
//		
//		body.setFixedRotation(false);
//		FixtureDef fixtureDef = new FixtureDef();
//		fixtureDef.shape = shape;
//		fixtureDef.density = 1.0f;
//		fixtureDef.friction = 5.0f;
//		body.createFixture(fixtureDef);
//		shape.dispose();
	}
	public Sprite getSprite() {
		return sprite;
	}
	public Body getBody() {
		return body;
	}
	public boolean isRemove() {
		return remove;
	}
	public int getType() {
		return type;
	}
	public void init (Stage stage) {
		this.stage = stage;
	}
	public abstract void render(SpriteBatch spriteBatch);
	public abstract void tick();
	//public abstract boolean collision(Entity e);
	public void die() {
		// TODO Auto-generated method stub
		remove = true;
	}
	public void dispose() {
		// TODO Auto-generated method stub
		if (body != null) world.destroyBody(body);
		sprite = null;
		System.gc();
	}
	public void explode() {
		// TODO Auto-generated method stub
		
	}
	public abstract void checkCollision(Entity c);
	
	public abstract void AttackBound(ShapeRenderer renderer);
	
}
